using System;
using Microsoft.Xna.Framework;

namespace GameEngine.Units
{
	// TODO: Pretty much a copy of the Slash Attack... should turn into custom one
	public class ComboAttack : Action
	{
		private static readonly long damageTime = new TimeSpan(0, 0, 0, 0, 400).Ticks;

		private long time;
		private bool damageDone;

		public ComboAttack(Unit owner)
			: base(owner)
		{
			this.time = new TimeSpan(0, 0, 0, 0, 830).Ticks;
			this.damageDone = false;
		}
		protected internal override bool Update(ref GameTime gameTime)
		{
			time = time - gameTime.ElapsedGameTime.Ticks;
			this.Owner.PlayAnimation("Attack");
			if (!this.damageDone && time <= ComboAttack.damageTime) // do not deal damage at the end of the action but rather at the middle... add option Actions to be interruptable - for example moving is but attach or casting spell should not
			{
				this.damageDone = true;
				this.World.SlashDamage(this.Owner, 15, 13, MathHelper.PiOver2);
			}
			return time <= 0;
		}
	}
}
